// jMap.cpp : Implementation of DLL Exports.


// Note: Proxy/Stub Information
//      To build a separate proxy/stub DLL, 
//      run nmake -f jMapps.mk in the project directory.

#include "stdafx.h"
#include "resource.h"
#include <initguid.h>
#include "jMap.h"

#include "jMap_i.c"

#include "Maps/Geometries/Point.h"
#include "Maps/Geometries/BoundingBox.h"
#include "Maps/Geometries/LineString.h"
#include "Maps/Geometries/LinearRing.h"
#include "Maps/Geometries/Polygon.h"
#include "Maps/Geometries/MultiLineString.h"
#include "Maps/Geometries/MultiPolygon.h"
#include "Maps/Geometries/MultiPoint.h"
#include "Maps/Geometries/Layer.h"
#include "Maps/Geometries/Map.h"
#include "Maps/Geometries/Providers.h"
#include "Maps/Geometries/FeatureData.h"
#include "Maps/Geometries/styles.h"

using namespace JMap_Geometries;
using namespace JMap_Layers;
using namespace JMap_Map;
using namespace JMap_Providers;
using namespace JMap_Data;

CComModule _Module;

BEGIN_OBJECT_MAP(ObjectMap)
	OBJECT_ENTRY(CLSID_cmPoint,JMap_Geometries::Point)
	OBJECT_ENTRY(CLSID_cmBoundingBox,BoundingBox)
	OBJECT_ENTRY(CLSID_cmLineString,LineString)
	OBJECT_ENTRY(CLSID_cmLinearRing,LinearRing)
	OBJECT_ENTRY(CLSID_cmPolygon,Polygon)
	OBJECT_ENTRY(CLSID_cmMultiLineString,MultiLineString)
	OBJECT_ENTRY(CLSID_cmMultiPolygon,MultiPolygon)
	OBJECT_ENTRY(CLSID_cmMultiPoint,MultiPoint)
	OBJECT_ENTRY(CLSID_cmVectorLayer,VectorLayer)
	OBJECT_ENTRY(CLSID_cmMap,Map)
	OBJECT_ENTRY(CLSID_cmShapeFile,ShapeFile)
	OBJECT_ENTRY(CLSID_cmFeatureDataRow,FeatureDataRow)
	OBJECT_ENTRY(CLSID_cmFeatureDataSet,FeatureDataSet)
	OBJECT_ENTRY(CLSID_cmFeatureDataTable,FeatureDataTable)
	OBJECT_ENTRY(CLSID_cmVectorStyle,VectorStyle)
	OBJECT_ENTRY(CLSID_cmLayers,Layers)

END_OBJECT_MAP()



class CJMapApp : public CWinApp
{
public:

	// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CGPSObjectsApp)
public:
	virtual BOOL InitInstance();
	virtual int ExitInstance();
	//}}AFX_VIRTUAL

	//{{AFX_MSG(CGPSObjectsApp)
	// NOTE - the ClassWizard will add and remove member functions here.
	//    DO NOT EDIT what you see in these blocks of generated code !
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

BEGIN_MESSAGE_MAP(CJMapApp, CWinApp)
	//{{AFX_MSG_MAP(CGPSObjectsApp)
	// NOTE - the ClassWizard will add and remove mapping macros here.
	//    DO NOT EDIT what you see in these blocks of generated code!
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

CJMapApp theApp;

BOOL CJMapApp::InitInstance()
{
	AfxEnableControlContainer();
	_Module.Init(ObjectMap, m_hInstance, &LIBID_JMAPLib);
	return CWinApp::InitInstance();
}

int CJMapApp::ExitInstance()
{
	_Module.Term();
	return CWinApp::ExitInstance();
}

/////////////////////////////////////////////////////////////////////////////
// DLL Entry Point

/*
extern "C"
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID / *lpReserved* /)
{
    if (dwReason == DLL_PROCESS_ATTACH)
    {
        _Module.Init(ObjectMap, hInstance, &LIBID_JMAPLib);
        DisableThreadLibraryCalls(hInstance);
    }
    else if (dwReason == DLL_PROCESS_DETACH)
        _Module.Term();

    return TRUE;    // ok
}
*/

/////////////////////////////////////////////////////////////////////////////
// Used to determine whether the DLL can be unloaded by OLE

STDAPI DllCanUnloadNow(void)
{
    return (_Module.GetLockCount()==0) ? S_OK : S_FALSE;
}

/////////////////////////////////////////////////////////////////////////////
// Returns a class factory to create an object of the requested type

STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
{
    return _Module.GetClassObject(rclsid, riid, ppv);
}

/////////////////////////////////////////////////////////////////////////////
// DllRegisterServer - Adds entries to the system registry

STDAPI DllRegisterServer(void)
{
    // registers object, typelib and all interfaces in typelib
    return _Module.RegisterServer(TRUE);
}

/////////////////////////////////////////////////////////////////////////////
// DllUnregisterServer - Removes entries from the system registry

STDAPI DllUnregisterServer(void)
{
    return _Module.UnregisterServer(TRUE);
}


